/*
 * @Description:
 * @Author: Evan Zhang. evan.holmes@foxmail.com
 * @Date: 2023-01-09 11:39:37
 * @LastEditTime: 2024-05-20 11:27:37
 * @LastEditors: Evan Zhang. evan.holmes@foxmail.com
 * @Reference:
 */
import nodeResolve from '@rollup/plugin-node-resolve'
import replace from '@rollup/plugin-replace'
import { terser } from 'rollup-plugin-terser'
import filesize from 'rollup-plugin-filesize'
import commonjs from '@rollup/plugin-commonjs'
import { babel } from '@rollup/plugin-babel'

const env = process.env.env_type
const isProdEnv = env === 'production'

const FILE_NAME = 'eDrag.js'
const config = {
	input: './src/index.js',
	output: {
		name: FILE_NAME,
		file: `dist/umd/${FILE_NAME}.umd.js`,
		format: 'umd',
		sourcemap: true
	}
}

const plugins = [
	nodeResolve(),
	babel({
		exclude: '**/node_modules/**',
		babelHelpers: 'bundled'
	}),
	isProdEnv && filesize(),
	replace({
		'process.env.NODE_ENV': JSON.stringify(env)
	}),
	commonjs(),
	isProdEnv && terser()
].filter(Boolean)

config.plugins = plugins

export default config
